package cn.jhc.bean;

import java.util.HashSet;

import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;

@Entity
@Table(name="teacher")
public class Teacher {

	private Integer tid;
	private String teacherno;
	private String tpassword;
	private String teachername;
	private String sex;
	
	private Set<Study> studies = new HashSet<Study>();
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="TID")
	public Integer getTid() {
		return tid;
	}

	public void setTid(Integer tid) {
		this.tid = tid;
	}
	
	@Column(name="TNO",columnDefinition="varchar(255)",unique=true)
	public String getTeacherno() {
		return teacherno;
	}
	public void setTeacherno(String teacherno) {
		this.teacherno = teacherno;
	}
	@Column(name="TPASSWORD",columnDefinition="varchar(255)")
	public String getTpassword() {
		return tpassword;
	}
	public void setTpassword(String tpassword) {
		this.tpassword = tpassword;
	}
	@Column(name="TNAME",columnDefinition="varchar(255)")
	public String getTeachername() {
		return teachername;
	}
	public void setTeachername(String teachername) {
		this.teachername = teachername;
	}
	@Column(name="SEX",columnDefinition="varchar(255)")
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	@OneToMany (mappedBy="teacher")  
    @Cascade (org.hibernate.annotations.CascadeType.SAVE_UPDATE)   
	public Set<Study> getStudies() {
		return studies;
	}
	public void setStudies(Set<Study> studies) {
		this.studies = studies;
	}
	

}
